
import httpUtils from "./XmlHttpTool";
var taskItem = cc.Class({
    name: 'taskItem',
    properties: {

        rankName:cc.String,
        rankheadimage:cc.Integer,
        status:cc.String
      
    }
});


cc.Class({
    extends: cc.Component,

    properties: {
        
        items: {
            default: [],
            type: taskItem
        },
        itemPrefab: cc.Prefab,
        bageAllScrollView:cc.Node,
        bageCloseBtn:cc.Button,
        emptyView:cc.Node,
        emptyLabel:cc.Node,
        moretitleSprite:cc.Node

    },


    closeClick:function(){


        var changebig = cc.scaleTo(0.02,1.2);

        var finish = cc.callFunc(function(){
    
            var that=this
          var changesmail = cc.scaleTo(0.08,1.0);

          var smaillfinish=cc.callFunc(function(){

            that.bageAllScrollView.active=false

          })

          var seq2 = cc.sequence(changesmail,smaillfinish)
          this.bageCloseBtn.node.runAction(seq2)
       

       }, this);
    
       var seq = cc.sequence(changebig,finish)

       this.bageCloseBtn.node.runAction(seq)

    

    },

    onLoad () {
  
        

    },

    init(){

        var that =this
        cc.loader.load({url: "https://h5.taoqi001.com/minigames/mouse_click/mouseImage/tasktitle.png", type: 'png'}, function (err, img) {
          var mylogo  = new cc.SpriteFrame(img); 
  
          that.moretitleSprite.getComponent(cc.Sprite).spriteFrame = mylogo;
    
        });

        if(this.items.length>0){
            this.node.removeAllChildren();
        }

        var that=this
        httpUtils.NhttpPost("/marmot/task_list",{},function(res){
            
            that.items=res
            console.log("任务列表",res)  
            if(res.tip){
                console.log("数组为0")
                that.emptyView.active=true
                that.emptyLabel.active=true
            }
            
            for (var i = 0; i < that.items.length; ++i) {
            
                var item = cc.instantiate(that.itemPrefab);
                that.node.addChild(item);
                item.getComponent('taskPrefab').init(that.items[i]);
             
            }
        })

    },

    start () {

    }


});
